/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author niit
 */
@Entity
@Table(name = "fl_member")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "FlMember.findAll", query = "SELECT f FROM FlMember f"),
    @NamedQuery(name = "FlMember.findByMemberid", query = "SELECT f FROM FlMember f WHERE f.memberid = :memberid"),
    @NamedQuery(name = "FlMember.findByUsename", query = "SELECT f FROM FlMember f WHERE f.usename = :usename"),
    @NamedQuery(name = "FlMember.findByPasswd", query = "SELECT f FROM FlMember f WHERE f.passwd = :passwd"),
    @NamedQuery(name = "FlMember.findByEmail", query = "SELECT f FROM FlMember f WHERE f.email = :email"),
    @NamedQuery(name = "FlMember.findByBlock", query = "SELECT f FROM FlMember f WHERE f.block = :block")})
public class FlMember implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "memberid")
    private Integer memberid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "usename")
    private String usename;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "passwd")
    private String passwd;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "email")
    private String email;
    @Column(name = "block")
    private Boolean block;
    @Lob
    @Size(max = 65535)
    @Column(name = "image")
    private String image;
    @OneToMany(mappedBy = "memberid")
    private List<FlAdmin> flAdminList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memberid")
    private List<FlFaculty> flFacultyList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "memberid")
    private List<FlStudent> flStudentList;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "flMember")
    private FlMembergroup flMembergroup;

    public FlMember() {
    }

    public FlMember(Integer memberid) {
        this.memberid = memberid;
    }

    public FlMember(Integer memberid, String usename, String passwd, String email) {
        this.memberid = memberid;
        this.usename = usename;
        this.passwd = passwd;
        this.email = email;
    }

    public Integer getMemberid() {
        return memberid;
    }

    public void setMemberid(Integer memberid) {
        this.memberid = memberid;
    }

    public String getUsename() {
        return usename;
    }

    public void setUsename(String usename) {
        this.usename = usename;
    }

    public String getPasswd() {
        return passwd;
    }

    public void setPasswd(String passwd) {
        this.passwd = passwd;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getBlock() {
        return block;
    }

    public void setBlock(Boolean block) {
        this.block = block;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    @XmlTransient
    public List<FlAdmin> getFlAdminList() {
        return flAdminList;
    }

    public void setFlAdminList(List<FlAdmin> flAdminList) {
        this.flAdminList = flAdminList;
    }

    @XmlTransient
    public List<FlFaculty> getFlFacultyList() {
        return flFacultyList;
    }

    public void setFlFacultyList(List<FlFaculty> flFacultyList) {
        this.flFacultyList = flFacultyList;
    }

    @XmlTransient
    public List<FlStudent> getFlStudentList() {
        return flStudentList;
    }

    public void setFlStudentList(List<FlStudent> flStudentList) {
        this.flStudentList = flStudentList;
    }

    public FlMembergroup getFlMembergroup() {
        return flMembergroup;
    }

    public void setFlMembergroup(FlMembergroup flMembergroup) {
        this.flMembergroup = flMembergroup;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (memberid != null ? memberid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof FlMember)) {
            return false;
        }
        FlMember other = (FlMember) object;
        if ((this.memberid == null && other.memberid != null) || (this.memberid != null && !this.memberid.equals(other.memberid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.FlMember[ memberid=" + memberid + " ]";
    }
    
}
